package net.maku.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

 
@Configuration
public class RestTemplateConfig {

    @Bean
    public RestTemplate restTemplate(){
        SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
        //连接20秒超时
        requestFactory.setConnectTimeout(30*1000);
        //读数20秒超时
        requestFactory.setReadTimeout(30*1000);
        return new RestTemplate(requestFactory);
    }
}

